package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.OrdersConfirmDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.dto.OrdersRejectionDTO;
import com.sky.entity.Orders;
import com.sky.vo.OrderStatisticsVO;
import com.sky.vo.OrderVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper {





    /**
     * 订单添加
     * @param order
     */
    void insert(Orders order);

    /**
     * 根据订单号查询订单
     * @param orderNumber
     */
    @Select("select * from orders where number = #{orderNumber}")
    Orders getByNumber(String orderNumber);

    /**
     * 修改订单信息
     * @param orders
     */
    void update(Orders orders);

    /** admin
     * 订单搜索
     * @param ordersPageQueryDTO
     */
    Page<Orders> conditionSearch(OrdersPageQueryDTO ordersPageQueryDTO);

    /**
     * 各个状态的订单数量统计
     * @param status
     * @return
     */
    @Select("select count(id) from orders where status = #{status}")
    Integer countStatus(Integer status);

    /**
     * 查询订单详细
     * @param id
     * @return
     */
    @Select("select  * from orders where id=#{id}")
    Orders details(Long id);

    /**
     * 接单
     * @param ordersConfirmDTO
     */
    void confirm(OrdersConfirmDTO ordersConfirmDTO);

    /**
     * 拒单
     * @param ordersRejectionDTO
     */
    void rejection(OrdersRejectionDTO ordersRejectionDTO);

    /**
     *  由状态和时间 来查询订单
     * @param pendingPayment
     * @param localDateTime
     */
    @Select("select  * from  orders where status=#{pendingPayment} and order_time<#{localDateTime}")
    List<Orders> getByStatusAndOrderTime(Integer pendingPayment, LocalDateTime localDateTime);

    Integer findOrdersOrSTATUS(LocalDateTime of, LocalDateTime of1, Integer status);

    /**
     * 当天营业额
     * @param begin
     * @param end
     * @param completed
     * @return
     */
    Double findsumMoney(LocalDateTime begin, LocalDateTime end, Integer completed);
}
